package com.lyfam.annotation.builder;

import com.vaadin.data.Item;
import com.vaadin.ui.Component;
import com.vaadin.ui.DefaultFieldFactory;
import com.vaadin.ui.Field;

public class FieldFactory extends DefaultFieldFactory
{
    private FieldBuilder builder;
    
    @Override
    public Field createField(Item item, Object propertyId, Component uiContext)
    {
        Field f = builder.getField((String) propertyId);
        
        if (f == null)
        {
            f = super.createField(item, propertyId, uiContext);
        }
        
        return f;
    }

    public FieldBuilder getBuilder()
    {
        return builder;
    }

    public void setBuilder(FieldBuilder builder)
    {
        this.builder = builder;
    }

}
